﻿using System.Collections;
using UnityEngine;
using XLua_Ki;

public class LuaClass_Demo : MonoBehaviour
{
    void Start()
    {
        string mainABRoot = Application.dataPath + @"\XLua\MiniKimmy\Examples\04_LuaClass\streamingassets\MiniKimmy_LuaClass\";

        GameObject obj = new GameObject("MiniKimmy");
        obj.AddComponent<GameManager_Ki>();
        DontDestroyOnLoad(obj);

        StartCoroutine(TestLuaClass(mainABRoot));
    }

    IEnumerator TestLuaClass(string mainABRoot)
    {
        GameManager_Ki.Instance.GetResourcesManager_Ki().LoadALLABPrefabs(mainABRoot);

        Debug.Log("MiniKimmy : wait for 3s ...");
        int wait = 0;
        while (wait < 3)
        {
            wait++;
            Debug.Log("MiniKimmy :" + (3 - wait) + "...");
            yield return new WaitForSeconds(1f);
        }

        LuaUtil.CallLuaPathAction(GameManager_Ki.Instance.LuaEnv, "luaclass_demo.Start");
    }
}